package inet.app.view.activity;

import inet.app.R;
import inet.app.common.XoSoConstants;
import inet.app.model.lottery.GetLoto;
import inet.app.model.lottery.LotteryResult;
import inet.app.model.object.KqGiai_Item;
import inet.app.model.util.DateProc;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Random;

import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

/*public class QuaythuActivity extends BaseActivity*/
public class QuaythuActivity extends BaseFragmentActivity {
	private String dau0, dau1, dau2, dau3, dau4, dau5, dau6, dau7, dau8, dau9,
			duoi0, duoi1, duoi2, duoi3, duoi4, duoi5, duoi6, duoi7, duoi8,
			duoi9, kqDe = "";
	private LotteryResult lotteryresult;
	private String date_curent;
	String giaidb = ".....";
	String giai1 = ".....";
	String giai2 = ".....-.....";
	String giai3 = ".....-.....-.....-.....-.....-.....";
	String giai4 = ".....-.....-.....-.....";
	String giai5 = ".....-.....-.....-.....-.....-.....";
	String giai6 = ".....-.....-.....";
	String giai7 = ".....-.....-.....-.....";
	String giai8 = ".....";
	private String x;
	private int i1, i2, i3, i4, i5, i6;
	private int numberGiai = 5;
	int sleep = 100;
	private String name;
	WebView webView;
	private ArrayList<String> arr_x = new ArrayList<String>();
	int[] photos = { R.drawable.imv0, R.drawable.imv1, R.drawable.imv2,
			R.drawable.imv3, R.drawable.imv4, R.drawable.imv5, R.drawable.imv6,
			R.drawable.imv7, R.drawable.imv8, R.drawable.imv9 };
	private int k = 0;
	KqGiai_Item list_kq;
	ArrayList<KqGiai_Item> arraylist = new ArrayList<KqGiai_Item>();
	Random ran;
	Dialog dialog;
	Handler hl, hl1;
	String capso;
	Runnable run, run1;
	boolean quay = false; // Bien nay xac dinh co' cho so' quay hay ko
	int kq, de, kqde;
	int kqdb, kq11, kq12, kq21, kq22, kq23, kq24, kq31, kq32, kq33, kq34, kq35,
			kq36;
	int kq41, kq42, kq43, kq44, kq45, kq46, kq47, kq51, kq52, kq53, kq54, kq55,
			kq56, kq61, kq62, kq63, kq71, kq72, kq73, kq74, kq81;
	int randomNumber;
	EditText etsode;
	Button btmayman;
	//
	Button btsoicau, btquay;
	TextView tvketqualoto, tvxemngaytruoc, tvtkloto, tvtime, tvdbtrue8,
			tvGiaiQuay, tvTitle;
	private ImageView imv1, imv2, imv3, imv4, imv5, imv6;
	Typeface tf;
	Dialog about;
	Random random;
	List<String> listrandom = new ArrayList<String>();

	Thread timer, timer1;
	int orange = Color.rgb(255, 150, 0);
	int blue = Color.rgb(0, 150, 255);
	int Green1 = Color.rgb(0, 255, 0);
	int Yellow1 = Color.rgb(255, 255, 0);
	int Red1 = Color.rgb(255, 0, 0);
	int heavyblue = Color.rgb(0, 0, 255);
	Spinner spSearchDiadiem;
	SharedPreferences data;
	int searchtype = 0;
	int selectedPeriod;
	SharedPreferences.Editor editor;
	public static final String filename = "TimePeriod";
	private TextView tvfotter;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.quaythu_screen);
		initBase();
		initUI();
		implementUI();

	}

	private void initUI() {
		date_curent = DateProc.Timestamp2DDMMYYYY(DateProc.createTimestamp());
		tvfotter = (TextView) findViewById(R.id.tvfotter);
		tvTitle = (TextView) findViewById(R.id.tvTitle);
		tvTitle.setText("Quay Thử");
		final Animation text_animation = AnimationUtils.loadAnimation(this,
				R.anim.custom_text_animation);
		tvfotter.startAnimation(text_animation);

		tvfotter.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent myWebLink = new Intent(
						android.content.Intent.ACTION_VIEW);
				myWebLink.setData(Uri.parse("http://m.ole.vn/"));
				startActivity(myWebLink);
			}
		});
		// WEBVIEW
		webView = (WebView) findViewById(R.id.webView);
		tvGiaiQuay = (TextView) findViewById(R.id.tvGiaiQuay);

		imv1 = (ImageView) findViewById(R.id.imv1);
		imv2 = (ImageView) findViewById(R.id.imv2);
		imv3 = (ImageView) findViewById(R.id.imv3);
		imv4 = (ImageView) findViewById(R.id.imv4);
		imv5 = (ImageView) findViewById(R.id.imv5);
		imv6 = (ImageView) findViewById(R.id.imv6);
		imv6.setVisibility(View.GONE);

		// Setup webview
		webView.setWebViewClient(new MyWebViewClient());
		webView.getSettings().setJavaScriptEnabled(true);
		webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
		webView.getSettings().setPluginsEnabled(true);
		webView.getSettings().setSupportMultipleWindows(true);
		webView.getSettings().setSupportZoom(false);
		webView.setVerticalScrollBarEnabled(true);
		webView.setHorizontalScrollBarEnabled(false);

		tf = Typeface.createFromAsset(getAssets(), "fonts/myFont.TTF");
		searchtype = 0;
		btquay = (Button) findViewById(R.id.btquay);

		spSearchDiadiem = (Spinner) findViewById(R.id.spSearchDiadiem);

		btquay.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (quay != true) {
					btquay.setText("Tạm dừng");
					quay = true;
				} else {
					quay = false;
					btquay.setText("Tiếp tục");
				}
			}
		});

		final String[] loaitimkiem = new String[] { " Xổ Số Thủ Đô",
				"Xổ Số TP HCM", "Xổ Số An Giang", "Xổ Số Bình Dương",
				"Xổ Số Bình Phước", "Xổ Số Bạc Liêu", "Xổ Số Bến Tre",
				"Xổ Số Cà Mau", "Xổ Số Cần Thơ", "Xổ Số Hậu Giang",
				"Xổ Số Kiên Giang", "Xổ Số Long An", "Xổ Số Sóc Trăng",
				"Xổ Số Tiền Giang", "Xổ Số Trà Vinh", "Xổ Số Tây Ninh",
				"Xổ Số Vĩnh Long", "Xổ Số Vũng Tàu", "Xổ Số Đà Lạt",
				"Xổ Số Đồng Nai", "Xổ Số Đồng Tháp", "Xổ Số Bình Thuận",
				"Xổ Số Bình Định", "Xổ Số Đắk Lắk", "Xổ Số Gia Lai",
				"Xổ Số Khánh Hòa", "Xổ Số Kon Tum", "Xổ Số Ninh Thuận",
				"Xổ Số Phú Yên", "Xổ Số Quảng Bình", "Xổ Số Quảng Nam",
				"Xổ Số Quảng Ngãi", "Xổ Số Quảng Trị", "Xổ Số Thừa Thiên Huế",
				"Xổ Số Đà Nẵng", "Xổ Số Đắc Nông" };

		ArrayAdapter<String> loaitkadapter = new ArrayAdapter<String>(
				QuaythuActivity.this, android.R.layout.simple_spinner_item,
				loaitimkiem);
		loaitkadapter
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spSearchDiadiem.setAdapter(loaitkadapter);
		spSearchDiadiem
				.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

					public void onItemSelected(AdapterView<?> arg0, View v,
							int pos, long id) {
						switch (pos) {
						case 0:
							searchtype = 0;
							numberGiai = 5;
							name = loaitimkiem[pos];
							arr_x.clear();
							k = 0;
							tvGiaiQuay.setText(" Giải nhất :");
							btquay.setText("Bắt đầu");
							quay = false;
							imv1.setImageResource(photos[0]);
							imv2.setImageResource(photos[0]);
							imv3.setImageResource(photos[0]);
							imv4.setImageResource(photos[0]);
							imv5.setImageResource(photos[0]);

							imv3.setVisibility(View.VISIBLE);
							imv4.setVisibility(View.VISIBLE);
							imv5.setVisibility(View.VISIBLE);
							imv6.setVisibility(View.GONE);

							giaidb = ".....";
							giai1 = ".....";
							giai2 = ".....-.....";
							giai3 = ".....-.....-.....-.....-.....-.....";
							giai4 = ".....-.....-.....-.....";
							giai5 = ".....-.....-.....-.....-.....-.....";
							giai6 = ".....-.....-.....";
							giai7 = ".....-.....-.....-.....";
							list_kq = new KqGiai_Item("XSMB", name,
									date_curent, giaidb, giai1, giai2, giai3,
									giai4, giai5, giai6, giai7, ".....");
							Load_data_webviewMB(list_kq);

							break;
						default:
							searchtype = 1;
							arr_x.clear();
							k = 0;
							tvGiaiQuay.setText(" Giải tám :");
							btquay.setText("Bắt đầu");
							numberGiai = 2;
							name = loaitimkiem[pos];
							quay = false;
							imv1.setImageResource(photos[0]);
							imv2.setImageResource(photos[0]);

							imv3.setVisibility(View.GONE);
							imv4.setVisibility(View.GONE);
							imv5.setVisibility(View.GONE);
							imv6.setVisibility(View.GONE);
							giaidb = ".....";
							giai1 = ".....";
							giai2 = ".....";
							giai3 = ".....-.....";
							giai4 = ".....-.....-.....-.....-.....-.....-.....";
							giai5 = ".....";
							giai6 = ".....-.....-.....";
							giai7 = ".....";
							giai8 = ".....";
							list_kq = new KqGiai_Item("XSTN", name,
									date_curent, giaidb, giai1, giai2, giai3,
									giai4, giai5, giai6, giai7, giai8);
							Load_data_webviewTN(list_kq);
							break;
						}
					}

					public void onNothingSelected(AdapterView<?> arg0) {
					}
				});

		de = -1; // Khong phai quan tam den cai nay nghich thoi
		ran = new Random(); // Khoi tao bien Random
		hl = new Handler(); // Khoi tao Handler de xu ly luong UI Thread

		run = new Runnable() { // Khoi tao 1 luong bang Runable (Runnable co tac
								// dung update UI Thread chua text view khac voi
								// Run)
			public void run() {

				if (quay) {
					if (numberGiai == 6) {
						i1 = ran.nextInt(photos.length);
						i2 = ran.nextInt(photos.length);
						i3 = ran.nextInt(photos.length);
						i4 = ran.nextInt(photos.length);
						i5 = ran.nextInt(photos.length);
						i6 = ran.nextInt(photos.length);

						x = i1 + "" + i2 + "" + i3 + "" + i4 + "" + i5 + ""
								+ i6;
						imv1.setImageResource(photos[i1]);
						imv2.setImageResource(photos[i2]);
						imv3.setImageResource(photos[i3]);
						imv4.setImageResource(photos[i4]);
						imv5.setImageResource(photos[i5]);
						imv6.setImageResource(photos[i6]);

						imv3.setVisibility(View.VISIBLE);
						imv4.setVisibility(View.VISIBLE);
						imv5.setVisibility(View.VISIBLE);
						imv6.setVisibility(View.VISIBLE);
					} else if (numberGiai == 5) {
						i1 = ran.nextInt(photos.length);
						i2 = ran.nextInt(photos.length);
						i3 = ran.nextInt(photos.length);
						i4 = ran.nextInt(photos.length);
						i5 = ran.nextInt(photos.length);

						x = i1 + "" + i2 + "" + i3 + "" + i4 + "" + i5;
						imv1.setImageResource(photos[i1]);
						imv2.setImageResource(photos[i2]);
						imv3.setImageResource(photos[i3]);
						imv4.setImageResource(photos[i4]);
						imv5.setImageResource(photos[i5]);
						imv3.setVisibility(View.VISIBLE);
						imv4.setVisibility(View.VISIBLE);
						imv5.setVisibility(View.VISIBLE);
						imv6.setVisibility(View.GONE);
					} else if (numberGiai == 4) {
						i1 = ran.nextInt(photos.length);
						i2 = ran.nextInt(photos.length);
						i3 = ran.nextInt(photos.length);
						i4 = ran.nextInt(photos.length);

						x = i1 + "" + i2 + "" + i3 + "" + i4;
						imv1.setImageResource(photos[i1]);
						imv2.setImageResource(photos[i2]);
						imv3.setImageResource(photos[i3]);
						imv4.setImageResource(photos[i4]);
						imv3.setVisibility(View.VISIBLE);
						imv4.setVisibility(View.VISIBLE);
						imv5.setVisibility(View.GONE);
						imv6.setVisibility(View.GONE);

					} else if (numberGiai == 3) {
						i1 = ran.nextInt(photos.length);
						i2 = ran.nextInt(photos.length);
						i3 = ran.nextInt(photos.length);

						x = i1 + "" + i2 + "" + i3;
						imv1.setImageResource(photos[i1]);
						imv2.setImageResource(photos[i2]);
						imv3.setImageResource(photos[i3]);
						imv3.setVisibility(View.VISIBLE);
						imv4.setVisibility(View.GONE);
						imv5.setVisibility(View.GONE);
						imv6.setVisibility(View.GONE);

					} else if (numberGiai == 2) {
						i1 = ran.nextInt(photos.length);
						i2 = ran.nextInt(photos.length);

						x = i1 + "" + i2;
						imv1.setImageResource(photos[i1]);
						imv2.setImageResource(photos[i2]);
						imv3.setVisibility(View.GONE);
						imv4.setVisibility(View.GONE);
						imv5.setVisibility(View.GONE);
						imv6.setVisibility(View.GONE);

					}
					k++;
					if (k == 10) {
						sleep = 1000;
						k = 0;
						arr_x.add(x);// Thêm vào mảng Array kết quả
						if (searchtype == 0) {
							System.out.println("TYPE = 000000000000000000000");
							giai1 = (arr_x.size() >= 1 ? arr_x.get(0) : ".....");
							giai2 = (arr_x.size() >= 2 ? arr_x.get(1) : ".....")
									+ "-"
									+ (arr_x.size() >= 3 ? arr_x.get(2)
											: ".....");
							giai3 = (arr_x.size() >= 4 ? arr_x.get(3) : ".....")
									+ "-"
									+ (arr_x.size() >= 5 ? arr_x.get(4)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 6 ? arr_x.get(5)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 7 ? arr_x.get(6)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 8 ? arr_x.get(7)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 9 ? arr_x.get(8)
											: ".....");
							giai4 = (arr_x.size() >= 10 ? arr_x.get(9)
									: ".....")
									+ "-"
									+ (arr_x.size() >= 11 ? arr_x.get(10)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 12 ? arr_x.get(11)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 13 ? arr_x.get(12)
											: ".....");
							giai5 = (arr_x.size() >= 14 ? arr_x.get(13)
									: ".....")
									+ "-"
									+ (arr_x.size() >= 15 ? arr_x.get(14)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 16 ? arr_x.get(15)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 17 ? arr_x.get(16)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 18 ? arr_x.get(17)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 19 ? arr_x.get(18)
											: ".....");
							giai6 = (arr_x.size() >= 20 ? arr_x.get(19)
									: ".....")
									+ "-"
									+ (arr_x.size() >= 21 ? arr_x.get(20)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 22 ? arr_x.get(21)
											: ".....");
							giai7 = (arr_x.size() >= 23 ? arr_x.get(22)
									: ".....")
									+ "-"
									+ (arr_x.size() >= 24 ? arr_x.get(23)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 25 ? arr_x.get(24)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 26 ? arr_x.get(25)
											: ".....");
							giaidb = (arr_x.size() >= 27 ? arr_x.get(26)
									: ".....");
							giai8 = "";
							System.out.println("GIAI 1 " + giai1);
							System.out.println("NUmber Giai" + numberGiai);

							if (giai1.contains(".....")) {
								numberGiai = 5;
								tvGiaiQuay.setText(" Giải Nhất :");
							} else if (giai2.contains(".....")) {
								numberGiai = 5;
								tvGiaiQuay.setText(" Giải Nhì :");
							} else if (giai3.contains(".....")) {
								numberGiai = 5;
								tvGiaiQuay.setText(" Giải Ba :");
							} else if (giai4.contains(".....")) {
								numberGiai = 4;
								tvGiaiQuay.setText(" Giải Tư :");
							} else if (giai5.contains(".....")) {
								numberGiai = 4;
								tvGiaiQuay.setText(" Giải Năm :");
							} else if (giai6.contains(".....")) {
								numberGiai = 3;
								tvGiaiQuay.setText(" Giải Sáu :");
							} else if (giai7.contains(".....")) {
								numberGiai = 2;
								tvGiaiQuay.setText(" Giải Bảy :");
							} else if (giaidb.contains(".....")) {
								numberGiai = 5;
								tvGiaiQuay.setText(" Giải ĐB :");
							}

							if (arr_x.size() >= 27) {
								quay = false;
								numberGiai = 5;
								arr_x.clear();
								btquay.setText("Bắt đầu");
								Toast.makeText(QuaythuActivity.this,
										"Đã quay xong!", Toast.LENGTH_LONG)
										.show();
							}

							System.out.println("GIA TRỊ DUNG LẠI LÀ " + i1 + ""
									+ i2 + "" + i3 + "" + i4 + "" + i5 + ""
									+ i6);
							list_kq = new KqGiai_Item("XSMB", name,
									date_curent, giaidb, giai1, giai2, giai3,
									giai4, giai5, giai6, giai7, "00");
							Load_data_webviewMB(list_kq);
						} else {
							System.out
									.println("TYPE = 11111111111111111111111111");
							giai8 = (arr_x.size() >= 1 ? arr_x.get(0) : ".....");
							giai7 = (arr_x.size() >= 2 ? arr_x.get(1) : ".....");
							giai6 = (arr_x.size() >= 3 ? arr_x.get(2) : ".....")
									+ "-"
									+ (arr_x.size() >= 4 ? arr_x.get(3)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 5 ? arr_x.get(4)
											: ".....");
							giai5 = (arr_x.size() >= 6 ? arr_x.get(5) : ".....");
							giai4 = (arr_x.size() >= 7 ? arr_x.get(6) : ".....")
									+ "-"
									+ (arr_x.size() >= 8 ? arr_x.get(7)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 9 ? arr_x.get(8)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 10 ? arr_x.get(9)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 11 ? arr_x.get(10)
											: ".....")
									+ "-"
									+ (arr_x.size() >= 12 ? arr_x.get(11)
											: ".....")
									+ "-"
									+ (arr_x.size() > 13 ? arr_x.get(12)
											: ".....");
							;
							giai3 = (arr_x.size() >= 14 ? arr_x.get(13)
									: ".....")
									+ "-"
									+ (arr_x.size() >= 15 ? arr_x.get(14)
											: ".....");
							giai2 = (arr_x.size() >= 16 ? arr_x.get(15)
									: ".....");
							giai1 = (arr_x.size() >= 17 ? arr_x.get(16)
									: ".....");
							giaidb = (arr_x.size() >= 18 ? arr_x.get(17)
									: ".....");
							System.out.println("GIAI 1 " + giai1);
							System.out.println("NUmber Giai" + numberGiai);

							if (giai8.contains(".....")) {
								System.out.println("Run 8");
								numberGiai = 2;
								tvGiaiQuay.setText(" Giải Tám :");
							} else if (giai7.contains(".....")) {
								System.out.println("Run 7");
								numberGiai = 3;
								tvGiaiQuay.setText(" Giải Bảy :");
							} else if (giai6.contains(".....")) {
								System.out.println("Run 6");
								numberGiai = 4;
								tvGiaiQuay.setText(" Giải Sáu :");
							} else if (giai5.contains(".....")) {
								numberGiai = 4;
								tvGiaiQuay.setText(" Giải Năm :");
							} else if (giai4.contains(".....")) {
								numberGiai = 5;
								tvGiaiQuay.setText(" Giải Tư :");
							} else if (giai3.contains(".....")) {
								numberGiai = 5;
								tvGiaiQuay.setText(" Giải Ba :");
							} else if (giai2.contains(".....")) {
								numberGiai = 5;
								tvGiaiQuay.setText(" Giải Nhì :");
							} else if (giai1.contains(".....")) {
								numberGiai = 5;
								tvGiaiQuay.setText(" Giải Nhất :");
							} else if (giaidb.contains(".....")) {
								numberGiai = 6;
								tvGiaiQuay.setText(" Giải ĐB :");
							}

							if (arr_x.size() >= 18) {
								quay = false;
								numberGiai = 2;
								arr_x.clear();
								btquay.setText("Bắt đầu");
								Toast.makeText(QuaythuActivity.this,
										"Đã quay xong!", Toast.LENGTH_LONG)
										.show();
							}
							list_kq = new KqGiai_Item("XSMT", name,
									date_curent, giaidb, giai1, giai2, giai3,
									giai4, giai5, giai6, giai7, giai8);
							Load_data_webviewTN(list_kq);
						}
					} else {
						sleep = 100;
					}
				}
				hl.postDelayed(this, sleep); // Lap lai luon sau 1 khoang thoi
												// gian 100 milisec
			}
		};
		hl.post(run); // Chay Runalbe vua khai bao

	}

	private void implementUI() {
		// TODO Auto-generated method stub

	}

	private void showRandomInteger(int aStart, int aEnd, Random aRandom) {
		if (aStart > aEnd) {
			throw new IllegalArgumentException("Start cannot exceed End.");
		}
		// get the range, casting to long to avoid overflow problems
		long range = (long) aEnd - (long) aStart + 1;
		// compute a fraction of the range, 0 <= frac < range
		long fraction = (long) (range * aRandom.nextDouble());
		randomNumber = (int) (fraction + aStart);
		log("Generated : " + randomNumber);
		listrandom.add(Integer.toString(randomNumber));
	}

	private static void log(String aMessage) {
		System.out.println(aMessage);
	}

	public void onBackPressed() {
		finish();
		return;
	}

	public void showProgressDialog(Activity act) {
		if (dialog == null) {
			dialog = ProgressDialog.show(act, "", "Đang tải...", true, true);
			Thread progress = new Thread() {
				@Override
				public void run() {
					while (((MyApp) getApplication()).isCanNext() == false) {
					}

					if (((MyApp) getApplication()).isCanNext() == true) {
						dialog.dismiss();
					}
				}
			};
			progress.start();
		} else if (!dialog.isShowing()) {
			dialog = ProgressDialog.show(act, "", "Đang tải...", true, true);
			Thread progress = new Thread() {
				@Override
				public void run() {
					while (((MyApp) getApplication()).isCanNext() == false) {
					}

					if (((MyApp) getApplication()).isCanNext() == true) {
						dialog.dismiss();

					}
				}
			};
			progress.start();
		}

	}

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			System.out.println("THOAT NHE");
			showQuitDialog(QuaythuActivity.this);
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	private void Load_data_webviewMB(KqGiai_Item arraylist) {
		// TODO Auto-generated method stub
		dau0 = "";
		dau1 = "";
		dau2 = "";
		dau3 = "";
		dau4 = "";
		dau5 = "";
		dau6 = "";
		dau7 = "";
		dau8 = "";
		dau9 = "";
		duoi0 = "";
		duoi1 = "";
		duoi2 = "";
		duoi3 = "";
		duoi4 = "";
		duoi5 = "";
		duoi6 = "";
		duoi7 = "";
		duoi8 = "";
		duoi9 = "";

		String giaidb, giai1;
		if (arraylist.getGiaidb().equals(""))
			giaidb = ".....";
		else
			giaidb = arraylist.getGiaidb();
		// ĐỀ
		kqDe = giaidb.substring(giaidb.length() - 2, giaidb.length());

		if (arraylist.getGiai1().equals(""))
			giai1 = ".....";
		else
			giai1 = arraylist.getGiai1();

		String[] giai2 = (arraylist.getGiai2() + "-.....-.....-").split("-");
		String[] giai3 = (arraylist.getGiai3() + "-.....-.....-.....-.....-.....-.....-")
				.split("-");
		String[] giai4 = (arraylist.getGiai4() + "-.....-.....-.....-.....-")
				.split("-");
		String[] giai5 = (arraylist.getGiai5() + "-.....-.....-.....-.....-.....-.....-")
				.split("-");
		String[] giai6 = (arraylist.getGiai6() + "-.....-.....-.....-")
				.split("-");
		String[] giai7 = (arraylist.getGiai7() + "-.....-.....-.....-.....-")
				.split("-");
		// ---------------------------------- Parser DAU
		// DUOI-----------------------------------//
		lotteryresult = new LotteryResult(giaidb, giai1, arraylist.getGiai2(),
				arraylist.getGiai3(), arraylist.getGiai4(),
				arraylist.getGiai5(), arraylist.getGiai6(),
				arraylist.getGiai7());

		GetLoto getloto = new GetLoto();
		String numberfirts, numberend;
		Collection<String> cEndNumbers = getloto.getEndNumberOfLotteryResult(
				lotteryresult, 2);
		String endNumber = "";
		for (Iterator<String> it = cEndNumbers.iterator(); it.hasNext();) {
			endNumber = it.next();
			numberfirts = Character.toString(endNumber.charAt(0));
			numberend = Character.toString(endNumber.charAt(1));
			// ĐẦU
			if (numberfirts.equals("0") == true)
				dau0 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("1") == true)
				dau1 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("2") == true)
				dau2 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("3") == true)
				dau3 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("4") == true)
				dau4 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("5") == true)
				dau5 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("6") == true)
				dau6 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("7") == true)
				dau7 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("8") == true)
				dau8 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("9") == true)
				dau9 += endNumber.substring(1, 2) + " ";
			// ĐUÔI
			if (numberend.equals("0") == true)
				duoi0 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("1") == true)
				duoi1 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("2") == true)
				duoi2 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("3") == true)
				duoi3 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("4") == true)
				duoi4 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("5") == true)
				duoi5 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("6") == true)
				duoi6 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("7") == true)
				duoi7 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("8") == true)
				duoi8 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("9") == true)
				duoi9 += endNumber.substring(0, 1) + " ";
		}
		// Clear the cache
		webView.clearCache(true);
		String htmlKetqua = "";
		int dauDe = 0, duoiDe = 0;
		if (!kqDe.contains("..") && kqDe != null) {
			dauDe = Integer.parseInt(kqDe.substring(0, 1));
			duoiDe = Integer.parseInt(kqDe.substring(1));
		}
		switch (dauDe) {
		case 0:
			dau0 = dau0.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 1:
			dau1 = dau1.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 2:
			dau2 = dau2.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 3:
			dau3 = dau3.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 4:
			dau4 = dau4.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 5:
			dau5 = dau5.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 6:
			dau6 = dau6.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 7:
			dau7 = dau7.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 8:
			dau8 = dau8.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 9:
			dau9 = dau9.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;

		default:
			break;
		}

		switch (duoiDe) {
		case 0:
			duoi0 = duoi0.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 1:
			duoi1 = duoi1.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 2:
			duoi2 = dau2.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 3:
			duoi3 = duoi3.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 4:
			duoi4 = duoi4.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 5:
			duoi5 = duoi5.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 6:
			duoi6 = duoi6.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 7:
			duoi7 = duoi7.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 8:
			duoi8 = duoi8.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 9:
			duoi9 = duoi9.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;

		default:
			break;
		}

		htmlKetqua += "<div>"
				+ "<div  style=\"cursor: pointer; margin:0 0 0 0; background-color:#323232;width: 100%\">"
				+ "<input style=\"background-color:#323232; color:#ffffff; height:30px; width:100%; font-size:11px; font-weight:bold; float:right; position:relative;\" type=\"button\" name=\"desel\" value=\""
				+ "Kết Quả "
				+ arraylist.getName()
				+ " - "
				+ arraylist.getDate()
				+ "\" onclick=\"window.location.href='"
				+ arraylist.getCode()
				+ "'\" >"
				+ "</div>"
				+ "<div>"
				+ "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">"
				+ "<tr>"
				+ "<td width=\"90%\" valign=\"top\" colspan=\"12\">"
				+ "<table width=\"100%\"  border=\"0\" cellspacing=\"1\" bgcolor=\"#CCCCCC\" cellpadding=\"0\">"
				+ "<tr bgcolor=\"#FFFFFF\">"
				+ "<td width=\"10%\" height=\"35\"  align=\"center\"  class=\"right\" style=\"color:red;\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_db.png\" width=\"35\" height=\"35\"/>"
				+ "</td>"
				+ "<td width=\"90%\" align=\"center\" style=\"color:red;\" colspan=\"12\">"
				+ giaidb
				+ "</td>"
				+ "</tr>"
				+

				"<tr bgcolor=\"#FFFFFF\">"
				+ "<td width=\"10%\" height=\"30\"  align=\"center\" class=\"fontsize12 black-text1\" colspan=\"12\">"
				+ "<img src=\"file:///android_res/drawable/img_g1.png\" width=\"35\" height=\"35\"/>"
				+ "</td>"
				+ "<td class=\"fontsize14a black-text5\" align=\"center\" colspan=\"12\">"
				+ giai1
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\">"
				+ "<td height=\"30\"  align=\"center\" class=\"left\" colspan=\"12\">"
				+ "<img src=\"file:///android_res/drawable/img_g2.png\" width=\"35\" height=\"35\"/>"
				+ "</td>"
				+ "<td class=\"right\" width=\"50%\" align=\"center\" colspan=\"6\"> "
				+ giai2[0]
				+ "</td>"
				+ "<td class=\"right\" width=\"50%\" align=\"center\" colspan=\"6\"> "
				+ giai2[1]
				+ "</td>"
				+ "</tr>"
				+

				"<tr bgcolor=\"#FFFFFF\" height=\"30\">"
				+ "<td height=\"30\"   align=\"center\" class=\"fontsize12 black-text1\" rowspan=\"2\" colspan=\"12\">"
				+ "<img src=\"file:///android_res/drawable/img_giai3.png\" width=\"35\" height=\"70\"/>"
				+ "</td>"
				+ "<td class=\"fontsize14a black-text5\" width=\"30%\" style=\"padding: 5px 0pt;\" align=\"center\" colspan=\"4\">"
				+ giai3[0]
				+ "</td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" colspan=\"4\">"
				+ giai3[1]
				+ "</td> "
				+ "<td class=\"right\" align=\"center\" width=\"30%\" colspan=\"4\">"
				+ giai3[2]
				+ "</td> "
				+ "</tr>"
				+

				" <tr bgcolor=\"#FFFFFF\" height=\"30\" > "
				+ "<td height=\"30\" class=\"right\" width=\"30%\" align=\"center\" colspan=\"4\"> "
				+ giai3[3]
				+ "</td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" colspan=\"4\">"
				+ giai3[4]
				+ "</td> "
				+ "<td class=\"right\" align=\"center\" width=\"30%\" colspan=\"4\">"
				+ giai3[5]
				+ "</td> "
				+ "</tr>"
				+

				"<tr bgcolor=\"#FFFFFF\">"
				+ "<td height=\"30\" align=\"center\" class=\"left\" colspan=\"12\">"
				+ "<img src=\"file:///android_res/drawable/img_g4.png\" width=\"35\" height=\"35\"/>"
				+ "</td>"
				+ "<td height=\"30\" class=\"right\" width=\"25%\" align=\"center\" colspan=\"3\">"
				+ giai4[0]
				+ "</td>"
				+ "<td class=\"right\" align=\"center\" width=\"25%\" colspan=\"3\"> "
				+ giai4[1]
				+ "</td>"
				+ "<td class=\"right\" align=\"center\" width=\"25%\" colspan=\"3\">"
				+ giai4[2]
				+ "</td> "
				+ "<td class=\"right\" align=\"center\" width=\"25%\" colspan=\"3\">"
				+ giai4[3]
				+ "</td> "
				+ "</tr>"
				+

				"<tr bgcolor=\"#FFFFFF\" height=\"30\">"
				+ "<td height=\"30\"  align=\"center\" class=\"left\" rowspan=\"2\" colspan=\"12\">"
				+ "<img src=\"file:///android_res/drawable/img_giai5.png\" width=\"35\" height=\"70\"/>"
				+ "</td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" colspan=\"4\">"
				+ giai5[0]
				+ "</td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" colspan=\"4\">"
				+ giai5[1]
				+ "</td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" colspan=\"4\">"
				+ giai5[2]
				+ "</td> "
				+ "</tr>"
				+ " <tr bgcolor=\"#FFFFFF\" height=\"30\"> "
				+ "<td height=\"30\" class=\"right\" align=\"center\" width=\"30%\" colspan=\"4\"> "
				+ giai5[3]
				+ "</td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" colspan=\"4\">"
				+ giai5[4]
				+ "</td> "
				+ "<td class=\"right\" align=\"center\" width=\"30%\" colspan=\"4\">"
				+ giai5[5]
				+ "</td> "
				+ "</tr>"
				+

				"<tr bgcolor=\"#FFFFFF\">"
				+ "<td height=\"30\"  align=\"center\" class=\"fontsize12 black-text1\" colspan=\"12\">"
				+ "<img src=\"file:///android_res/drawable/img_g6.png\" width=\"35\" height=\"35\"/>"
				+ "</td>"
				+ "<td class=\"fontsize14a black-text5\" width=\"30%\" align=\"center\" colspan=\"4\">"
				+ giai6[0]
				+ "</td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" colspan=\"4\">"
				+ giai6[1]
				+ "</td> "
				+ "<td class=\"right\" align=\"center\" width=\"30%\" colspan=\"4\">"
				+ giai6[2]
				+ "</td> "
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\">"
				+ "<td height=\"30\"  align=\"center\" class=\"fontsize12 black-text1\" colspan=\"12\">"
				+ "<img src=\"file:///android_res/drawable/img_g7.png\" width=\"35\" height=\"35\"/>"
				+ "</td>"
				+ "<td class=\"fontsize14a black-text5\" width=\"30%\" align=\"center\" colspan=\"3\">"
				+ giai7[0]
				+ "</td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" colspan=\"3\"> "
				+ giai7[1]
				+ "</td>"
				+ "<td class=\"right\" align=\"center\" width=\"30%\" colspan=\"3\">"
				+ giai7[2]
				+ "</td> "
				+ "<td class=\"right\" align=\"center\" width=\"30%\" colspan=\"3\">"
				+ giai7[3] + "</td> " + "</tr>" +

				"</table>" + "</td>" + "</tr>" + "</table>" + "</div>";

		// -------------------------DAU DUOI----------------------------
		String htmldauduoi = "";
		htmldauduoi += "<div>"
				+ "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">"
				+ "<tr>"
				+ "<td width=\"50%\" valign=\"top\" colspan=\"12\">"
				+ "<table width=\"100%\"  border=\"0\" bgcolor=\"#CCCCCC\" cellspacing=\"1\" cellpadding=\"0\">"
				+

				"<tr bgcolor=\"#323232\" >"
				+ "<td width=\"10%\" height=\"28\"  align=\"center\" class=\"right\" style=\"color:#ffffff;\" colspan=\"12\" >Đầu</td>"
				+ "<td width=\"90%\" height=\"28\"  align=\"center\" class=\"right\" style=\"color:#ffffff;\" colspan=\"12\" >Lô Tô</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 0 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g0.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau0
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 1 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g1.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau1
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 2 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g2.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau2
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 3 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g3.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau3
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color"
				+ (dauDe != 4 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g4.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau4
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 5 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g5.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau5
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 6 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g6.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau6
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 7 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g7.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau7
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 8 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g8.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau8
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 9 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g9.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau9
				+ "</td>"
				+ "</tr>"
				+ "</table>"
				+ "</td>"
				+ "<td width=\"50%\" valign=\"top\" colspan=\"12\">"
				+ "<table width=\"100%\"  border=\"0\" bgcolor=\"#CCCCCC\" cellspacing=\"1\" cellpadding=\"0\" >"
				+ "<tr bgcolor=\"#323232\">"
				+ "<td width=\"10%\" height=\"28\"  align=\"center\" class=\"right\" style=\"color:#ffffff;\" colspan=\"12\" >Đít</td>"
				+ "<td width=\"90%\" height=\"28\"  align=\"center\" class=\"right\" style=\"color:#ffffff;\" colspan=\"12\" >Lô Tô</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 0 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g0.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi0
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 1 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g1.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi1
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 2 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g2.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi2
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 3 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g3.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi3
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 4 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g4.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi4
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 5 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g5.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi5
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 6 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g6.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi6
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 7 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g7.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi7
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 8 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g8.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi8
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 9 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g9.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi9 + "</td>" + "</tr>" + "</table>" + "</td>" +

				"</tr>" + "</table>" + "</div>";
		String htmlfooter = "<div style=\"margin:0 0 0 0; background-color:#323232; height:35px; text-align:center;\">"
				+ "<span style=\"background-color:#323232; text-align:center; color:#ffffff; font-size:13px; position:relative; top:10px\" class=\"fontsize12\">"
				+ "<strong>"
				+ "Chơi xổ số kiến thiết ích nước lợi nhà !"
				+ "</strong></span>" + "</div>";
		webView.loadDataWithBaseURL("file:///android_asset/",XoSoConstants.css+
				htmlKetqua + htmldauduoi + htmlfooter, "text/html", "utf-8",
				null);

	}

	private void Load_data_webviewTN(KqGiai_Item arraylist) {
		// TODO Auto-generated method stub
		dau0 = "";
		dau1 = "";
		dau2 = "";
		dau3 = "";
		dau4 = "";
		dau5 = "";
		dau6 = "";
		dau7 = "";
		dau8 = "";
		dau9 = "";
		duoi0 = "";
		duoi1 = "";
		duoi2 = "";
		duoi3 = "";
		duoi4 = "";
		duoi5 = "";
		duoi6 = "";
		duoi7 = "";
		duoi8 = "";
		duoi9 = "";
		webView.clearCache(true);
		String htmlKetqua = "";
		String giaidb, giai1, giai2, giai5, giai7, giai8;
		String[] giai3 = null;
		String[] giai4 = null;
		String[] giai6 = null;

		if (arraylist.getGiaidb().equals(""))
			giaidb = ".....";
		else
			giaidb = arraylist.getGiaidb();

		// ĐỀ
		kqDe = giaidb.substring(giaidb.length() - 2, giaidb.length());

		if (arraylist.getGiai1().equals(""))
			giai1 = ".....";
		else
			giai1 = arraylist.getGiai1();

		if (arraylist.getGiai2().equals(""))
			giai2 = ".....";
		else
			giai2 = arraylist.getGiai2();

		if (arraylist.getGiai5().equals(""))
			giai5 = ".....";
		else
			giai5 = arraylist.getGiai5();

		if (arraylist.getGiai7().equals(""))
			giai7 = ".....";
		else
			giai7 = arraylist.getGiai7();

		if (arraylist.getGiai8().equals(""))
			giai8 = ".....";
		else
			giai8 = arraylist.getGiai8();

		giai3 = (arraylist.getGiai3() + "-.....-.....-").split("-");
		giai4 = (arraylist.getGiai4() + "-.....-.....-.....-.....-.....-.....-.....-")
				.split("-");
		giai6 = (arraylist.getGiai6() + "-.....-.....-.....-").split("-");

		// ---------------------------------- Parser DAU
		// DUOI-----------------------------------//
		lotteryresult = new LotteryResult(giaidb, giai1, giai2,
				arraylist.getGiai3(), arraylist.getGiai4(), giai5,
				arraylist.getGiai6(), giai7, giai8);

		GetLoto getloto = new GetLoto();
		String numberfirts, numberend;
		Collection<String> cEndNumbers = getloto.getEndNumberOfLotteryResult(
				lotteryresult, 2);
		String endNumber = "";
		for (Iterator<String> it = cEndNumbers.iterator(); it.hasNext();) {
			endNumber = it.next();
			numberfirts = Character.toString(endNumber.charAt(0));
			numberend = Character.toString(endNumber.charAt(1));
			// ĐẦU
			if (numberfirts.equals("0") == true)
				dau0 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("1") == true)
				dau1 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("2") == true)
				dau2 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("3") == true)
				dau3 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("4") == true)
				dau4 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("5") == true)
				dau5 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("6") == true)
				dau6 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("7") == true)
				dau7 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("8") == true)
				dau8 += endNumber.substring(1, 2) + " ";
			if (numberfirts.equals("9") == true)
				dau9 += endNumber.substring(1, 2) + " ";
			// ĐUÔI
			if (numberend.equals("0") == true)
				duoi0 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("1") == true)
				duoi1 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("2") == true)
				duoi2 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("3") == true)
				duoi3 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("4") == true)
				duoi4 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("5") == true)
				duoi5 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("6") == true)
				duoi6 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("7") == true)
				duoi7 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("8") == true)
				duoi8 += endNumber.substring(0, 1) + " ";
			if (numberend.equals("9") == true)
				duoi9 += endNumber.substring(0, 1) + " ";
		}

		int dauDe = 0, duoiDe = 0;
		if (!kqDe.contains("..") && kqDe != null) {
			dauDe = Integer.parseInt(kqDe.substring(0, 1));
			duoiDe = Integer.parseInt(kqDe.substring(1));
		}
		switch (dauDe) {
		case 0:
			dau0 = dau0.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 1:
			dau1 = dau1.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 2:
			dau2 = dau2.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 3:
			dau3 = dau3.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 4:
			dau4 = dau4.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 5:
			dau5 = dau5.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 6:
			dau6 = dau6.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 7:
			dau7 = dau7.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 8:
			dau8 = dau8.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;
		case 9:
			dau9 = dau9.replaceAll(duoiDe + "", "<span style=\'color:red;\'>"
					+ duoiDe + "</span>");
			break;

		default:
			break;
		}

		switch (duoiDe) {
		case 0:
			duoi0 = duoi0.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 1:
			duoi1 = duoi1.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 2:
			duoi2 = dau2.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 3:
			duoi3 = duoi3.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 4:
			duoi4 = duoi4.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 5:
			duoi5 = duoi5.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 6:
			duoi6 = duoi6.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 7:
			duoi7 = duoi7.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 8:
			duoi8 = duoi8.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;
		case 9:
			duoi9 = duoi9.replaceAll(dauDe + "", "<span style=\'color:red;\'>"
					+ dauDe + "</span>");
			break;

		default:
			break;
		}

		htmlKetqua += "<div  style=\"cursor: pointer; margin:0 0 0 0; background-color:#323232;width: 100%\">"
				+ "<input style=\"background-color:#323232; color:#ffffff; height:30px; width:100%; font-size:11px; font-weight:bold; float:right; position:relative;\" type=\"button\" name=\"desel\" value=\""
				+ "Kết Quả "
				+ arraylist.getName()
				+ " - "
				+ arraylist.getDate()
				+ "\" onclick=\"window.location.href='"
				+ arraylist.getCode()
				+ "'\" >"
				+ "</div>"
				+ "<div><table width=\"100%\" border=\"0\"  bgcolor=\"#CCCCCC\" cellspacing=\"1\"style=\"text-align:center;\" cellpadding=\"0\">"
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\" width=\"10%\" >"
				+ "<img src=\"file:///android_res/drawable/img_g8.png\" width=\"35\" height=\"35\"/>"
				+ "</td>"
				+ "<td class=\"right\" colspan=\"12\">"
				+ giai8
				+ "</td> </tr> "
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\">"
				+ "<img src=\"file:///android_res/drawable/img_g7.png\" width=\"35\" height=\"35\"/>"
				+ "</td>"
				+ " <td class=\"right\" colspan=\"12\">"
				+ giai7
				+ "</td> </tr> "
				+ "<tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\">"
				+ "<img src=\"file:///android_res/drawable/img_g6.png\" width=\"35\" height=\"35\"/>"
				+ "</td>"
				+ " <td class=\"right\" width=\"35%\" colspan=\"4\">"
				+ giai6[0]
				+ "</td> <td class=\"right\" width=\"35%\"colspan=\"4\">"
				+ giai6[1]
				+ "</td> <td class=\"right\" width=\"35%\"colspan=\"4\">"
				+ giai6[2]
				+ "</td> </tr> "
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\">"
				+ "<img src=\"file:///android_res/drawable/img_g5.png\" width=\"35\" height=\"35\"/>"
				+ "</td>"

				+ " <td class=\"right\" colspan=\"12\">"
				+ giai5
				+ "</td> </tr>"
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\" rowspan=\"2\">"
				+ "<img src=\"file:///android_res/drawable/img_giai4.png\" width=\"35\" height=\"70\"/>"
				+ "</td>"
				+ " <td class=\"right\" width=\"25%\"colspan=\"3\">"
				+ giai4[0]
				+ "</td> <td class=\"right\" colspan=\"3\" width=\"25%\">"
				+ giai4[1]
				+ "</td> <td class=\"right\" colspan=\"3\" width=\"25%\">"
				+ giai4[2]
				+ "</td> <td class=\"right\" colspan=\"3\" width=\"25%\">"
				+ giai4[3]
				+ "</td> </tr> "
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"right\" colspan=\"4\" width=\"30%\">"
				+ giai4[4]
				+ "</td> <td class=\"right\" colspan=\"4\" width=\"30%\">"
				+ giai4[5]
				+ "</td> <td class=\"right\" colspan=\"4\" width=\"30%\">"
				+ giai4[6]
				+ "</td> </tr> "
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\">"
				+ "<img src=\"file:///android_res/drawable/img_g3.png\" width=\"35\" height=\"35\"/>"
				+ "</td>"
				+ " <td class=\"right\" colspan=\"6\" width=\"50%\">"
				+ giai3[0]
				+ "</td> <td class=\"right\" colspan=\"6\" width=\"50%\">"
				+ giai3[1]
				+ "</td> </tr>"
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\">"
				+ "<img src=\"file:///android_res/drawable/img_g2.png\" width=\"35\" height=\"35\"/>"
				+ "</td>"
				+ " <td class=\"right\" colspan=\"12\">"
				+ giai2
				+ "</td> </tr> "
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\">"
				+ "<img src=\"file:///android_res/drawable/img_g1.png\" width=\"35\" height=\"35\"/>"
				+ "</td>"
				+ " <td class=\"right\" colspan=\"12\">"
				+ giai1
				+ "</td> </tr> "
				+ " <tr class=\"hienso\"  bgcolor=\"#FFFFFF\" height=\"30\"> <td class=\"left\">"
				+ "<img src=\"file:///android_res/drawable/img_db.png\" width=\"35\" height=\"35\"/>"
				+ "</td>"
				+ " <td class=\"right\" style=\"color:red;\"colspan=\"12\">"
				+ giaidb + "</td> </tr>" + "</table></div>";
		// -----------------------------------------DAU
		// DUOI-------------------------------------//
		String htmldauduoi = "";
		htmldauduoi += "<div>"
				+ "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">"
				+ "<tr>"
				+ "<td width=\"50%\" valign=\"top\" colspan=\"12\">"
				+

				"<table width=\"100%\"  border=\"0\" bgcolor=\"#CCCCCC\" cellspacing=\"1\" cellpadding=\"0\">"
				+

				"<tr bgcolor=\"#323232\" >"
				+ "<td width=\"10%\" height=\"35\"  align=\"center\" class=\"right\" style=\"color:#ffffff;\" colspan=\"12\" >Đầu</td>"
				+ "<td width=\"90%\" height=\"35\"  align=\"center\" class=\"right\" style=\"color:#ffffff;\" colspan=\"12\" >Lô Tô</td>"
				+ "</tr>"
				+

				"<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 0 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g0.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau0
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 1 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g1.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau1
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 2 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g2.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau2
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 3 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g3.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau3
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 4 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g4.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau4
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 5 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g5.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau5
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 6 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g6.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau6
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 7 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g7.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau7
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 8 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g8.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau8
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (dauDe != 9 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g9.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ dau9
				+ "</td>"
				+ "</tr>"
				+

				"</table>"
				+

				"</td>"

				+

				"<td width=\"50%\" valign=\"top\" colspan=\"12\">"
				+

				"<table width=\"100%\"  border=\"0\" bgcolor=\"#CCCCCC\" cellspacing=\"1\" cellpadding=\"0\" >"
				+

				"<tr bgcolor=\"#323232\">"
				+ "<td width=\"10%\" height=\"35\"  align=\"center\" class=\"right\" style=\"color:#ffffff;\" colspan=\"12\" >Đít</td>"
				+ "<td width=\"90%\" height=\"35\"  align=\"center\" class=\"right\" style=\"color:#ffffff;\" colspan=\"12\" >Lô Tô</td>"
				+ "</tr>"
				+

				"<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 0 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g0.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi0
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 1 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g1.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi1
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 2 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g2.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi2
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 3 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g3.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi3
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 4 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g4.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi4
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 5 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g5.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi5
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 6 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g6.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi6
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 7 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g7.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi7
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 8 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g8.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi8
				+ "</td>"
				+ "</tr>"
				+ "<tr bgcolor=\"#FFFFFF\" >"
				+ "<td width=\"10%\" height=\"25\"  align=\"center\" class=\"right\" style=\"color:"
				+ (duoiDe != 9 ? "black" : "red")
				+ ";\" colspan=\"12\" >"
				+ "<img src=\"file:///android_res/drawable/img_g9.png\" width=\"30\" height=\"30\"/>"
				+ "</td>"
				+ "<td width=\"90%\" height=\"25\"  align=\"left\" class=\"right\" style=\"color:back;padding-left:5px;\" colspan=\"12\" >"
				+ duoi9 + "</td>" + "</tr>" + "</table>" +

				"</td>" +

				"</tr>" + "</table>" + "</div>";
		String htmlfooter = "<div style=\"margin:0 0 0 0; background-color:#323232; height:35px; text-align:center;\">"
				+ "<span style=\"background-color:#323232; text-align:center; color:#ffffff; font-size:13px; position:relative; top:10px\" class=\"fontsize12\">"
				+ "<strong>"
				+ "Chơi xổ số kiến thiết ích nước lợi nhà !"
				+ "</strong></span>" + "</div>";

		webView.loadDataWithBaseURL("file:///android_asset/",XoSoConstants.css+
				htmlKetqua + htmldauduoi + htmlfooter, "text/html", "utf-8",
				null);
	}

	private class MyWebViewClient extends WebViewClient {
		@Override
		public boolean shouldOverrideUrlLoading(WebView view, String url) {
			return true;
		}

		@Override
		public void onPageFinished(WebView view, String url) {
			// TODO Auto-generated method stub
			super.onPageFinished(view, url);
		}

		@Override
		public void onReceivedError(WebView view, int errorCode,
				String description, String failingUrl) {
			super.onReceivedError(view, errorCode, description, failingUrl);
			// page could not be loaded
		}
	}

	@Override
	public void onResume() {
		// TODO Auto-generated method stub
		if (((MyApp) getApplication()).isKill()) {
			finish();
		}
		super.onResume();

	}
}
